#include<stdio.h>
int main()
{
	int arr[] = { 1,2,3,4,5,6,7,8,9,10 };
	int left = 0;
	int k = 7;
	int right = sizeof(arr) / sizeof(arr[0]) - 1;
	while (left <= right)
	{
		int mid = (left + right) / 2;		
		if (arr[mid] > k)		//要查找的数在中间数字的左边
		{
			right = mid - 1;
		}
		else if (arr[mid] < k)	//要查找的数字在中间数字的有边
		{
			left = mid + 1;
		}
		else		//left==right ,直接跳出循环不再遍历
		{
			printf("找到了\n");
			break;
		}
	}
	if (left > right)
	{
		printf("没找到\n");
	}
}